package de.tu_darmstadt.gdi1.battleship.view;

import java.io.File;
import java.util.HashMap;


/**
 * Class containing the filenames of all images needed for a skin.
 * 
 */
public class Skin {

	// needed Images:
	// l, r, t, b, v, h, L, R, T, B, V, H, −, ∗ wie in Aufgabenstellung
	// # Treffer, noch nicht versenkt
	// | Border
	// f Nebel

	private HashMap<String, String> images = new HashMap<String, String>();

	/**
	 * create new Skin with given images.
	 * 
	 * @param left
	 * @param right
	 * @param top
	 * @param bottom
	 * @param vertical
	 * @param horizontal
	 * @param leftHit
	 * @param rigthHit
	 * @param topHit
	 * @param bottomHit
	 * @param verticalHit
	 * @param horizontalHit
	 * @param unknownHit
	 * @param water
	 * @param waterHit
	 * @param border
	 * @param fog
	 */
	public Skin(String left, String right, String top, String bottom,
			String vertical, String horizontal, String leftHit,
			String rightHit, String topHit, String bottomHit,
			String verticalHit, String horizontalHit, String unknownHit,
			String water, String waterHit, String border, String fog) {
		images.put("l", left);
		images.put("r", right);
		images.put("t", top);
		images.put("b", bottom);
		images.put("v", vertical);
		images.put("h", horizontal);
		images.put("L", leftHit);
		images.put("R", rightHit);
		images.put("T", topHit);
		images.put("B", bottomHit);
		images.put("V", verticalHit);
		images.put("H", horizontalHit);
		images.put("#", unknownHit);
		images.put("-", water);
		images.put("*", waterHit);
		images.put("|", border);
		images.put("f", fog);
	}

	/**
	 * creates new Skin by loading according Images from Folder
	 * 
	 * @param folder
	 *            must contain
	 */
	public Skin(File folder) {
		loadImagesFromFolder(folder);
	}

	/**
	 * creates new Skin with default images.
	 */
	public Skin() {
		// System.out.println(System.getProperty("user.dir"));
		// System.out.println();
		
		File f = new File("src/de/tu_darmstadt/gdi1/resources/images/defaultskin");
		loadImagesFromFolder(f);
	}

	public HashMap<String, String> getImages() {
		return images;
	}

	public void loadImagesFromFolder(File folder) {

		images.put("l", folder.getAbsolutePath() + "/ship_left.png");
		images.put("r", folder.getAbsolutePath() + "/ship_right.png");
		images.put("t", folder.getAbsolutePath() + "/ship_top.png");
		images.put("b", folder.getAbsolutePath() + "/ship_bottom.png");
		images.put("v", folder.getAbsolutePath() + "/ship_vertical.png");
		images.put("h", folder.getAbsolutePath() + "/ship_horizontal.png");
		images.put("L", folder.getAbsolutePath() + "/ship_hit_left.png");
		images.put("R", folder.getAbsolutePath() + "/ship_hit_right.png");
		images.put("T", folder.getAbsolutePath() + "/ship_hit_top.png");
		images.put("B", folder.getAbsolutePath() + "/ship_hit_bottom.png");
		images.put("V", folder.getAbsolutePath() + "/ship_hit_vertical.png");
		images.put("H", folder.getAbsolutePath() + "/ship_hit_horizontal.png");
		images.put("#", folder.getAbsolutePath() + "/ship_hit.png");
		images.put("-", folder.getAbsolutePath() + "/water.png");
		images.put("*", folder.getAbsolutePath() + "/water_hit.png");
		images.put("|", folder.getAbsolutePath() + "/border.png");
		images.put("f", folder.getAbsolutePath() + "/fogofwar.png");
		
		System.out.println("Skin loaded from:" + folder.getPath());

	}

}
